﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Microsoft.Practices.Unity;

using TheKitchen.Client.Querying;
using TheKitchen.Client.Services;

namespace TheKitchen.Client.ViewModels
{
    public class FindRecipesCoroutine : SimpleCoroutine
    {
        [Dependency]
        public IQueryAgent QueryAgent { get; set; }

        public string PartialName { get; set; }

        public string PartialDescription { get; set; }

        public int MinimumRating { get; set; }

        public IEnumerable<Recipe> Recipes { get; internal set; }

        protected override void OnExecute()
        {
            QueryAgent.FindRecipes(MinimumRating, PartialName, PartialDescription,
                recipes =>
                {
                    Recipes = recipes.ToArray();
                    OnComplete();
                });
        }
    }
}